<?php
//if (isset($_GET["msg"])) {
//    echo $_GET["msg"];
//}
//?>
<?php
define('UserPhotoPath','../../images/user/');//define定义常量
require_once('../Common/dbConn.php');//require_once引入其他文件
//连接数据库
connect();
//用户id是通过GET方法提交
$uid = $_GET['uid'];//删除的话找ID，而为什么找是因为删除按钮调的是id
$sql = "select * from users where uid = {$uid}";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$filename = UserPhotoPath.$row["pic"];//这个是删除头像文件。
if(file_exists($filename))	unlink($filename);
//删除数据库相应信息，如果删除成功，删除该用户的头像文件
$sql = "delete from users where uid = {$uid}";
$result = mysql_query($sql) or die ('删除失败!'.mysql_error());
$num = mysql_query($sql);
if ($num != 1){
    echo "删除失败,2秒后返回用户列表页";
    header("refresh:2;url='ht_userList.php'");
}else{
    header("location:ht_userList.php");
}
?>